package gold.digger;

import gold.utils.InputUtil;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC1252 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int oddCells(int m, int n, int[][] indices) {
            int[] rowAdd = new int[m], colAdd = new int[n];
            for (int[] index : indices) {
                rowAdd[index[0]]++;
                colAdd[index[1]]++;
            }

            int rowOdd = 0, rowEven = 0, colOdd = 0, colEven = 0;
            for (int i : rowAdd) {
                if (i % 2 == 0) rowEven++;
                else rowOdd++;
            }

            for (int i : colAdd) {
                if (i % 2 == 0) colEven++;
                else colOdd++;
            }

            return rowOdd * colEven + rowEven * colOdd;
        }
    }

    public void run() {
        System.out.println(new Solution().oddCells(2, 3, InputUtil.toDoubleIntegerArray("[[0,1],[1,1]]")));
        System.out.println(new Solution().oddCells(2, 2, InputUtil.toDoubleIntegerArray("[[1,1],[0,0]]")));
    }

    public static void main(String[] args) throws Exception {
        LC1252 an = new LC1252();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
